package com.css.fxfzdpzs.modules.qh.service.impl;

import com.css.fxfzdpzs.modules.qh.entity.*;
import com.css.fxfzdpzs.modules.qh.repository.QhRepository;
import com.css.fxfzdpzs.modules.qh.service.QhService;
import com.css.fxfzdpzs.modules.qh.vo.ProjectDrillGeomVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class QhServiceImpl implements QhService {
    @Autowired
    private QhRepository qhRepository;

    @Override
    public ProjectDrillNum getProjectDrillNum() {
        return qhRepository.getProjectDrillNum();
    }

    @Override
    public List<ProvinceCount> getProvinceCount(String type) {
        return qhRepository.getProvinceCount(type);
    }

    @Override
    public List<ProjectDrillRenew> getProjectDrillRenew() {
        return qhRepository.getProjectDrillRenew();
    }

    @Override
    public List<YearProjectDrillRenew> getYearProjectDrillRenew() {
        return qhRepository.getYearProjectDrillRenew();
    }

    @Override
    public List<WorkCategoryCount> getWorkCategoryCount() {
        return qhRepository.getWorkCategoryCount();
    }

    @Override
    public Map<String, List<ProjectDrillGeomVo>> getLonAndLat() {
        List<ProjectDrillGeomVo> list = qhRepository.getLonAndLat();
        Map<String, List<ProjectDrillGeomVo>> map = list.stream().collect(Collectors.groupingBy(ProjectDrillGeomVo::getCategory));
        return map;
    }
}
